<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="procurement_pro" :rules="rules" label-width="100px" id="mvcfm">
      <div class="form-unit">
        <span class="mvc-title-left"> 采购计划 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="标题" prop="pro_title">
              <el-input v-model="procurement_pro.pro_title" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="产品" prop="">
              {{procurement_pro.product_id}}
              <el-button @click="popSelectionOutsourcing('','product_id')" type="success" size="mini"><i class="fa fa-edit"></i>选择</el-button>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="采购数量" prop="pro_num">
              <el-input v-model="procurement_pro.pro_num" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="数量单位" prop="pro_nuit">
              <el-input v-model="procurement_pro.pro_nuit" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="计划入库时间" prop="storage_time">
              <el-date-picker v-model="procurement_pro.storage_time" type="date" style='width:100%' value-format="yyyy-MM-dd" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input type="textarea" v-model="procurement_pro.remark" ttparea=350></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <el-button @click="increaseProcurementSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('/psi/supplychainmana/PurchaseStatistical?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
    </el-form>
    <el-dialog :visible.sync="SelectionOutsourcingVisible" append-to-body>
      <SelectionOutsourcing v-if="SelectionOutsourcingVisible" ref="SelectionOutsourcing" :popparams="popparams"> </SelectionOutsourcing>
    </el-dialog>
  </div>
</template>
<script>
  import request from '@/utils/request'
  import SelectionOutsourcing from "@/views/psi/supplychainmana/SelectionOutsourcing";
  export default {
    name: 'IncreaseProcurement',
    components: {
      SelectionOutsourcing,
    },
    props: ['popparams'],
    data() {
      return {
        SelectionOutsourcingVisible: false,
        SelectionOutsourcingValue: null,
        SelectionOutsourcingDesc: null,
        vueparams: this.getVUEParams(""),
        procurement_pro: {
          pro_title: null,
          product_id: null,
          pro_num: null,
          pro_nuit: null,
          storage_time: null,
          remark: null,
        },
        loading: false,
        rules: {
          pro_title: [{
            required: true,
            message: "标题不能为空",
            trigger: 'blur',
          }],
          pro_num: [{
            required: true,
            message: "采购数量不能为空",
            trigger: 'blur',
          }],
          storage_time: [{
            required: true,
            message: "计划入库时间不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {},
    updated() {},
    mounted() {},
    methods: {
      increaseProcurementSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/psi/supplychainmana/PurchaseStatisticalAction/increaseProcurementSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/psi/supplychainmana/PurchaseStatistical/purchaseStatistical?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      popSelectionOutsourcing(desc, value) {
        this.SelectionOutsourcingVisible = true;
        this.SelectionOutsourcingDesc = desc;
        this.SelectionOutsourcingValue = value;
      },
      closeSelectionOutsourcing(value, desc) {
        this.SelectionOutsourcingVisible = false;
        this.$set(this.procurement_pro, this.SelectionOutsourcingDesc, desc);
        this.$set(this.procurement_pro, this.SelectionOutsourcingValue, value);
      },
    },
  }
</script>
